/*
 *    Thing Game Library
 *   Copyright (C)2005 - 2010 Eduardo Nunes Pereira (eduardonunesp at gmail dot com)
 *
 *   This program/library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 *   This program/library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 *    You should have received a copy of the GNU Lesser General Public
 * License along with this program/library ; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __KEYBOARD_HPP__
#define __KEYBOARD_HPP__

#include <SDL/SDL.h>
#include <map>
#include <string>

namespace Thing
{
    namespace Events
    {
        class Keyboard
        {
        public:
            struct Key
            {
                typedef enum 
                {
                    __FIRST__ = 0,
                    ESCAPE = SDLK_ESCAPE,
                    RETURN = SDLK_RETURN,
                    SPACE  = SDLK_SPACE,

                    A      = SDLK_a,
                    B      = SDLK_b,
                    C      = SDLK_c,
                    D      = SDLK_d,
                    E      = SDLK_e,
                    F      = SDLK_f,
                    G      = SDLK_g,
                    H      = SDLK_h,
                    I      = SDLK_i,
                    J      = SDLK_j,
                    K      = SDLK_k,
                    L      = SDLK_l,
                    M      = SDLK_m,
                    N      = SDLK_n,
                    O      = SDLK_o,
                    P      = SDLK_p,
                    Q      = SDLK_q,
                    R      = SDLK_r,
                    S      = SDLK_s,
                    T      = SDLK_t,
                    U      = SDLK_u,
                    V      = SDLK_v,
                    W      = SDLK_w,
                    X      = SDLK_x,
                    Y      = SDLK_y,
                    Z      = SDLK_z,

                    UP     = SDLK_UP,
                    DOWN   = SDLK_DOWN,
                    RIGHT  = SDLK_RIGHT,
                    LEFT   = SDLK_LEFT,
                    __LAST__   
                } Keys;

                struct KeyState
                {
                    typedef enum
                    {
                        RELEASED = SDL_RELEASED,
                        PRESSED  = SDL_PRESSED,  
                        CLEARED 
                    } States;
                };
                
                static std::string keyToString(int k);
                static std::string stateToString(int state);
            };

            typedef std::map<int, int> KeyMap;

            Keyboard() {}
            ~Keyboard() {}

            void setKeyState(int state, int k);
            int checkKeyState(int k);
            void clearState(int k);

        private:
            KeyMap _keys;
        };
    }
}

#endif /* __KEYBOARD_HPP__ */
